package Core.Map;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;


public class Path
{
	private List<Tile> _tiles;
	
	public Path()
	{
		this._tiles = new LinkedList<Tile>();
	}
	
	public void addTileToEndOfPath(Tile tile)
	{
		this._tiles.add(tile);
	}

	public Tile getLastTile()
	{
		Tile lastTile;
		
		if (this._tiles.size() <= 0)
		{
			lastTile = null;
		}
		else
		{
			lastTile = this._tiles.get(this._tiles.size() - 1);
		}
		
		return lastTile;
	}
	
	public Tile[] tiles()
	{
		return _tiles.toArray(new Tile[0]);
	}

	public void insertTile(Tile newTile, int step)
	{
		this._tiles.add(step - 1, newTile);
	}

	public Tile getTileAtStep(int step)
	{
		return this._tiles.get(step - 1);
	}
	
	public Iterator<Tile> getStepIterator()
	{
		return this._tiles.iterator();
	}
}
